package com.lonty.intelligence.service;

import com.lonty.intelligence.mapper.StreetKnowsMapper;
import com.lonty.intelligence.model.StreetKnows;
import com.lonty.intelligence.request.StreetKnowsList;
import com.lonty.intelligence.util.UUIDUtil;
import com.lonty.intelligence.vo.StreetKnowsVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author 陈璇
 * @Date 2020/6/28 10:51
 * @Version 1.0
 */
@Service
public class StreetKnowsService {

    @Resource
    private StreetKnowsMapper streetKnowsMapper;

    /**
     * 保存街道知道
     * @param streetKnowsVo
     * @return
     */
    public boolean saveStreetKnows(StreetKnowsVo streetKnowsVo){
        StreetKnows streetKnows = new StreetKnows();
        BeanUtils.copyProperties(streetKnowsVo, streetKnows);
        streetKnows.setId(UUIDUtil.randomID());
        streetKnows.setCreateTime(LocalDateTime.now());
        return streetKnowsMapper.saveStreetKnows(streetKnows) > 0;
    }

    /**
     * 获取街道知道列表
     * @return
     */
    public List<StreetKnowsList> getStreetKnowsList(){
        List<StreetKnowsList> streetKnowsListList = streetKnowsMapper.getStreetKnowsList();
        return streetKnowsListList;
    }

}
